#include <stdio.h>
#include <unistd.h>
//socket接口需要的头文件
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>

int main()
{
    //创建套接字
    int listen_sock =  socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    if(listen_sock < 0)
    {
        perror("socket");
        return 0;
    }
    //绑定地址信息
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(28989);
    addr.sin_addr.s_addr = inet_addr("0.0.0.0");
    //本地所有网卡地址
    int ret =  bind(listen_sock,(struct sockaddr*)&addr,sizeof(addr));
    if(ret < 0)
    {
        perror("bind");
        return 0;
    }
    ret = listen(listen_sock,1);
    if(ret < 0)
    {
        perror("listen");
        return 0;
    }
    while(1)
    {
        sleep(1);
    }

    return 0;
}
